<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
// 网站地址
String netPath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort();
%>
<!doctype html>
<head>
<meta charset="utf-8">
<title>增加公告弹出层</title>
<link href="<c:url value="/stylesheets/common.css"/>" rel="stylesheet" type="text/css" />
<link href="<c:url value="/stylesheets/account.css"/>" rel="stylesheet" type="text/css" />
<script  src="<c:url value="/javascripts/jquery.js"/>"></script>
<style>
.role_form{padding:20px 0 0 10px;}
.role_form .jsmc,.role_form textarea{width:320px;}
.linkhand { cursor: pointer;}
</style>
<script type="text/javascript">
/**
 *	提交之前的校验
 */
function validateSubmit(obj){
	var message = "";
	$("[data-required='true']").each(function(){
		var value = $(this).val();
		if(!value){
			var nullMessage = $(this).attr("null-message");
			message += nullMessage+"\n\r";
		}
	});

	if(message){
		alert(message);
		return false;
	}else{
		return true;
	}
};

/**
 * 增加公告
 */
 function add(obj){

    // 增加前检查
 	if(validateSubmit(obj)){
 		$("[name='addAdSubmit']").click();
 	}

};

//刷新栏目
function refreshLinks(){
	parent.$(".userContent").load("<%=basePath%>ad/showAds");
}
</script>
</head>
<body>
<div class="role_form">
<form:form modelAttribute="adLink" method="post" enctype="multipart/form-data" id="addLinkForm" action="/ad/toAdd">
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="jsgltable mt10">

  <tr>
    <td valign="middle"><p>内容：</p></td>
    <td valign="top">
    	<form:textarea path="theme" data-required="true"  null-message="公告内容不能为空 ！" placeholder="输入您要创建的公告内容" class="jsmc"/>
    	<input type="hidden" value="2" name="type"></input>
    </td>
  </tr>
<%--   <tr>
    <td valign="top"><p>排序：</p></td>
    <td width="85%" valign="top">
      <form:input path="sort" class="jsmc"/>
     </td>
  </tr> --%>
  <tr>
    <td valign="top"><p>链接：</p></td>
    <td width="85%" valign="top">
    	 <form:input path="url" class="jsmc"/>
     </td>
  </tr>
</table>
 <div class="btnblock ">
        <input name="Input" type="button" value="增加" onclick="add(this)" class="btngreen01 linkhand"/>
         <input name="addAdSubmit" type="submit" style="display:none;" />
 </div>
 </form:form>
 <script type="text/javascript">
 	var resultType = ${resultType};
 	if(resultType==1){
		alert("${resultMessage}");
		refreshLinks();
		parent.$.dialog.close();
 	} else if(resultType==0){
 		alert("${resultMessage}");
 	}
 </script>
</div>
</body>
</html>
